/*
 * SiFiSy - A File System Simulator
 * Copyright (C) 2010  SevenSoft
 *
 * This file is part of SiFiSy.
 *
 * SiFiSy is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SiFiSy is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with SiFiSy.  If not, see <http://www.gnu.org/licenses/>.
 */

package sifisy.newgui;

import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.border.TitledBorder;
import sifisy.core.Model;

/**
 * @author Giuseppe Biolo
 * @version %I%, %G%
 * @createData 12/05/2010
 */
public class AboutWidget extends JDialog {
    private JLabel SevenSoftLogo;
    private JLabel productVersion;
    private JButton closeButton;
    private JTextArea gpl;

    private void initComponents() {
        SevenSoftLogo = new JLabel(new ImageIcon(getClass().getResource("images/SevenSoftLogo.png")));
        productVersion = new JLabel(Model.translate("version" + ":"));//Model.Translate("versionLabel"));
        closeButton = new JButton(Model.translate("closeButton"));
        gpl = new JTextArea("SiFiSy is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. \n" +
                "SiFiSy is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. \n" +
                "You should have received a copy of the GNU General Public License along with SiFiSy.  If not, see <http://www.gnu.org/licenses/>.");
        gpl.setLineWrap(true);
        gpl.setEditable(false);
        closeButton.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                (AboutWidget.this).dispose();
            }
        });
    }

    public AboutWidget() {
        super(MainWidget.getMainWidgetFrame(), "About SiFiSy", true);
        initComponents();
        setLayout(new BorderLayout());

        JPanel vendor = new JPanel(new FlowLayout());
        vendor.setBorder(new TitledBorder(Model.translate("vendor")));
        vendor.add(SevenSoftLogo);

        JPanel licence = new JPanel(new GridLayout(1,1));
        licence.setBorder(new TitledBorder(Model.translate("license")));
        licence.add(gpl);

        JPanel version = new JPanel(new FlowLayout(FlowLayout.LEFT));
        version.setBorder(new TitledBorder(Model.translate("contact")));
        version.add(new JLabel("sevensoftse@gmail.com"));

        JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
        buttons.add(closeButton);

        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
        mainPanel.add(vendor);
        mainPanel.add(licence);
        mainPanel.add(version);
        
        add(mainPanel,BorderLayout.CENTER);
        add(buttons,BorderLayout.SOUTH);

        setSize(450,540);
        setLocationRelativeTo(MainWidget.getMainWidgetFrame());
        setVisible(true);
    }
}